//
//  ECMineSafeTopStyleCell.m
//  Edu_iOS2018
//
//  Created by apple on 2018/1/15.
//  Copyright © 2018年 yanyan. All rights reserved.
//

#import "ECMineSafeTopStyleCell.h"

@interface ECMineSafeTopStyleCell()

@property (nonatomic, strong) UILabel *typeLab;
@property (nonatomic, strong) UILabel *contentLab;
@property (nonatomic, strong) UIImageView *arrowView;
@property (nonatomic, strong) UIView *lineView;

@end

@implementation ECMineSafeTopStyleCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

+(ECMineSafeTopStyleCell *)tableViewCellWithTableView:(UITableView *)tableView{
    static NSString* identifier=@"ECMineSafeTopStyleCell";
    ECMineSafeTopStyleCell* cell=[tableView dequeueReusableCellWithIdentifier:identifier];
    if (cell==nil) {
        cell=[[ECMineSafeTopStyleCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
        cell.selectionStyle = 0;
        [cell setCellUI];
    }
    return cell;
}

-(void)setCellUI{
    self.typeLab = [[UILabel alloc]init];
    [self.contentView addSubview:self.typeLab];
    self.typeLab.textColor = [UIColor colorWithHexString:@"#999999"];
    
    self.contentLab = [[UILabel alloc]init];
    [self.contentView addSubview:self.contentLab];
    self.contentLab.textColor = [UIColor colorWithHexString:@"#171717"];
    self.contentLab.textAlignment = NSTextAlignmentRight;
    
    self.arrowView = [[UIImageView alloc]init];
    [self.contentView addSubview:self.arrowView];
    [self.arrowView setImage:[UIImage imageNamed:@"MIne_safeArrow"]];
    
    self.lineView = [[UIView alloc]init];
    [self.contentView addSubview:self.lineView];
    self.lineView.backgroundColor = [UIColor colorWithHexString:@"#F1F1F1"];
    
    WeakSelf(weakSelf);
    [self.typeLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.contentView.mas_left).offset(kProportion_Width(45));
        make.centerY.equalTo(weakSelf.contentView.mas_centerY);
        make.width.equalTo(@100);
        make.height.equalTo(@18);
    }];
    
    [self.arrowView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(weakSelf.contentView.mas_right).offset(-kProportion_Width(45));
        make.centerY.equalTo(self.typeLab.mas_centerY);
        make.width.equalTo(@(kProportion_Width(17)));
        make.height.equalTo(self.arrowView.mas_width).multipliedBy(38.f/17.f);
    }];
    
    [self.contentLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.arrowView.mas_right).offset(-10);
        make.centerY.equalTo(self.typeLab.mas_centerY);
        make.height.equalTo(self.typeLab.mas_height);
        make.left.equalTo(self.typeLab.mas_right);
    }];
    
    [self.lineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(weakSelf.contentView.mas_bottom);
        make.left.equalTo(weakSelf.contentView.mas_left).offset(kProportion_Width(45));
        make.right.equalTo(weakSelf.contentView.mas_right).offset(-kProportion_Width(45));
        make.height.equalTo(@1);
    }];
}

-(void)setContentWithData:(NSArray *)data andIndex:(NSIndexPath *)indexPath{
    self.typeLab.text = data[0];
    self.contentLab.text = data[1];
    
    if (indexPath.row == 1) {
        if (![data[1] isEqualToString:@""]) {
            self.contentLab.text = data[1];
        }else{
            self.contentLab.text = @"绑定手机";
        }
    }
    if (indexPath.row == 2) {//隐藏箭头
        self.arrowView.hidden = YES;
        
        if ([data[1] isEqualToString:@""]) {
            self.contentLab.text = @"请登录PC端验证";
            self.contentLab.textColor = [UIColor colorWithHexString:@"#a5a5a5"];
        }
    }
    if (indexPath.row == 3) {//隐藏分割线
        self.lineView.hidden = YES;
    }
}

@end
